package tree;

public class TreeDeep {
    public static int deep(TreeNode root) {
        if (root == null)
            return 0;
        int left = deep(root.getLeft());
        int right = deep(root.getRight());
        return left > right ? left + 1 : right + 1;
    }

    public static void main(String[] args)
    {
        int[] list = {1, 2, 0, 3, 4, 0, 0, 0, 5, 6, 0, 0, 7, 8, 9, 0, 0, 0, 0};
        TreeNode root = BuildTree.buildTree(list);
        System.out.println(deep(root));
    }
}
